{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e4f75e62",
   "metadata": {},
   "source": [
    "* 日期：2022-09-14 \n",
    "* 课程：python\n",
    "\n",
    "### 回顾与复习\n",
    "\n",
    "> for+ range()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "741833f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print (i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f413f0b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建有序数值（创建自然数）\n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "85a15834",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5))   #产生了5-0个值，默认从0开始 注：0(start) 5(stop)  每一次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f7e123d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range (2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d95efa46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(2,5))  #产生了5-2个值，start=2 stop=5 每一次增长1个单位 (step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "26551960",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9240a71a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d8f2f4e0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index.htm0.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm1.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm2.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm3.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm4.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm5.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm6.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm7.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm8.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm9.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm10.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm11.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm12.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm13.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm14.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm15.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm16.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm17.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm18.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm19.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm20.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm21.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm22.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm23.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm24.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm25.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm26.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm27.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm28.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm29.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm30.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm31.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm32.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm33.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm34.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm35.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm36.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm37.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm38.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm39.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm40.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm41.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm42.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm43.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm44.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm45.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm46.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm47.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm48.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm49.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm50.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm51.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm52.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm53.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm54.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm55.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm56.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm57.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm58.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm59.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm60.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm61.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm62.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm63.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm64.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm65.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm66.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm67.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm68.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm69.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm70.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm71.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm72.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm73.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm74.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm75.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm76.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm77.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm78.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm79.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm80.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm81.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm82.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm83.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm84.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm85.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm86.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm87.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm88.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm89.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm90.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm91.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm92.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm93.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm94.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm95.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm96.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm97.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm98.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm99.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm100.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm101.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm102.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm103.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm104.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm105.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm106.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm107.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm108.htm\n",
      "https://www.nfu.edu.cn/xxyw/index.htm109.htm\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成某个网站的所有页码的URL队列\n",
    "南方学院学校要闻 =\"https://www.nfu.edu.cn/xxyw/index.htm\"\n",
    "页面后缀 = \".htm\"\n",
    "page =110\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c6438f58",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结，for+range  for可以执行循环，range决定了循环体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "85d8527c",
   "metadata": {},
   "source": [
    "## 本周内容\n",
    "\n",
    "> 1.random模块  \n",
    "\n",
    ">>1.random.random():生成0-1之间的伪随机数  \n",
    "\n",
    ">> 2. random.randint(a,b):生成a-b之间的随机整数（整数)  \n",
    "\n",
    ">> 3. random.choice(): 随机生成一个序列的值（非空）\n",
    "\n",
    ">2. time 模块\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "2d1356ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1.random \n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "afcf96a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2666628932013574"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "32cb12f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "674dbb79",
   "metadata": {},
   "outputs": [],
   "source": [
    "import (random.randit）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "8445a683",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "module 'random' has no attribute 'randit'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_15668/399481468.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m## 2.randit\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mhelp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandit\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: module 'random' has no attribute 'randit'"
     ]
    }
   ],
   "source": [
    "## 2.randit\n",
    "\n",
    "help(random.randit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "376d367b",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'random' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_15668/342202609.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m6\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'random' is not defined"
     ]
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "181292c5",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "module 'random' has no attribute 'randit'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_15668/343687858.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mhelp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandit\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: module 'random' has no attribute 'randit'"
     ]
    }
   ],
   "source": [
    "help(random.randit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f5de3e87",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3. random.choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "71561857",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method choice in module random:\n",
      "\n",
      "choice(seq) method of random.Random instance\n",
      "    Choose a random element from a non-empty sequence.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.choice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "287a9cef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.choice(['a','b','c'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aaeb9424",
   "metadata": {},
   "source": [
    "### 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fe3b6443",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "896fb5c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d24bf87e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "e4558314",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index.htm0.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index.htm1.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index.htm2.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index.htm3.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index.htm4.htm\n",
      "该次停留 3 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成某个网站的所有页码的URL队列\n",
    "import random \n",
    "import time \n",
    "南方学院学校要闻 =\"https://www.nfu.edu.cn/xxyw/index.htm\"\n",
    "页面后缀 = \".htm\"\n",
    "page =5\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)  #字符号拼接\n",
    "    random_num = random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a594a681",
   "metadata": {},
   "source": [
    "## 3.课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "a266582d",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character '，' (U+FF0C) (Temp/ipykernel_15668/1783942401.py, line 21)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\1\\AppData\\Local\\Temp/ipykernel_15668/1783942401.py\"\u001b[1;36m, line \u001b[1;32m21\u001b[0m\n\u001b[1;33m    print(\"等待时间为：\"，wait_time)\u001b[0m\n\u001b[1;37m                  ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character '，' (U+FF0C)\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds = [1, 3,  5,  7,  9,  11,13,15,17,19, \n",
    "            21,23,25,27,29,31,33,35,37,39,\n",
    "           41, 43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_second = datetime.datetime.today().second\n",
    "\n",
    "for i in range (5):\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "       \n",
    "        \n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间为：\"，wait_time)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "bbcdb58b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上~~\n",
      "99 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "98 bottles 在啤酒墙上~~\n",
      "98 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "97 bottles 在啤酒墙上~~\n",
      "97 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "96 bottles 在啤酒墙上~~\n",
      "96 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "95 bottles 在啤酒墙上~~\n",
      "95 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "94 bottles 在啤酒墙上~~\n",
      "94 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "93 bottles 在啤酒墙上~~\n",
      "93 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "92 bottles 在啤酒墙上~~\n",
      "92 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "91 bottles 在啤酒墙上~~\n",
      "91 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "90 bottles 在啤酒墙上~~\n",
      "90 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "89 bottles 在啤酒墙上~~\n",
      "89 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "88 bottles 在啤酒墙上~~\n",
      "88 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "87 bottles 在啤酒墙上~~\n",
      "87 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "86 bottles 在啤酒墙上~~\n",
      "86 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "85 bottles 在啤酒墙上~~\n",
      "85 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "84 bottles 在啤酒墙上~~\n",
      "84 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "83 bottles 在啤酒墙上~~\n",
      "83 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "82 bottles 在啤酒墙上~~\n",
      "82 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "81 bottles 在啤酒墙上~~\n",
      "81 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "80 bottles 在啤酒墙上~~\n",
      "80 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "79 bottles 在啤酒墙上~~\n",
      "79 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "78 bottles 在啤酒墙上~~\n",
      "78 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "77 bottles 在啤酒墙上~~\n",
      "77 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "76 bottles 在啤酒墙上~~\n",
      "76 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "75 bottles 在啤酒墙上~~\n",
      "75 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "74 bottles 在啤酒墙上~~\n",
      "74 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "73 bottles 在啤酒墙上~~\n",
      "73 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "72 bottles 在啤酒墙上~~\n",
      "72 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "71 bottles 在啤酒墙上~~\n",
      "71 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "70 bottles 在啤酒墙上~~\n",
      "70 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "69 bottles 在啤酒墙上~~\n",
      "69 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "68 bottles 在啤酒墙上~~\n",
      "68 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "67 bottles 在啤酒墙上~~\n",
      "67 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "66 bottles 在啤酒墙上~~\n",
      "66 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "65 bottles 在啤酒墙上~~\n",
      "65 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "64 bottles 在啤酒墙上~~\n",
      "64 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "63 bottles 在啤酒墙上~~\n",
      "63 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "62 bottles 在啤酒墙上~~\n",
      "62 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "61 bottles 在啤酒墙上~~\n",
      "61 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "60 bottles 在啤酒墙上~~\n",
      "60 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "59 bottles 在啤酒墙上~~\n",
      "59 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "58 bottles 在啤酒墙上~~\n",
      "58 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "57 bottles 在啤酒墙上~~\n",
      "57 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "56 bottles 在啤酒墙上~~\n",
      "56 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "55 bottles 在啤酒墙上~~\n",
      "55 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "54 bottles 在啤酒墙上~~\n",
      "54 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "53 bottles 在啤酒墙上~~\n",
      "53 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "52 bottles 在啤酒墙上~~\n",
      "52 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "51 bottles 在啤酒墙上~~\n",
      "51 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "50 bottles 在啤酒墙上~~\n",
      "50 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "49 bottles 在啤酒墙上~~\n",
      "49 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "48 bottles 在啤酒墙上~~\n",
      "48 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "47 bottles 在啤酒墙上~~\n",
      "47 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "46 bottles 在啤酒墙上~~\n",
      "46 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "45 bottles 在啤酒墙上~~\n",
      "45 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "44 bottles 在啤酒墙上~~\n",
      "44 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "43 bottles 在啤酒墙上~~\n",
      "43 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "42 bottles 在啤酒墙上~~\n",
      "42 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "41 bottles 在啤酒墙上~~\n",
      "41 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "40 bottles 在啤酒墙上~~\n",
      "40 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "39 bottles 在啤酒墙上~~\n",
      "39 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "38 bottles 在啤酒墙上~~\n",
      "38 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "37 bottles 在啤酒墙上~~\n",
      "37 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "36 bottles 在啤酒墙上~~\n",
      "36 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "35 bottles 在啤酒墙上~~\n",
      "35 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "34 bottles 在啤酒墙上~~\n",
      "34 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "33 bottles 在啤酒墙上~~\n",
      "33 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "32 bottles 在啤酒墙上~~\n",
      "32 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "31 bottles 在啤酒墙上~~\n",
      "31 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "30 bottles 在啤酒墙上~~\n",
      "30 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "29 bottles 在啤酒墙上~~\n",
      "29 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "28 bottles 在啤酒墙上~~\n",
      "28 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "27 bottles 在啤酒墙上~~\n",
      "27 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "26 bottles 在啤酒墙上~~\n",
      "26 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "25 bottles 在啤酒墙上~~\n",
      "25 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "24 bottles 在啤酒墙上~~\n",
      "24 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "23 bottles 在啤酒墙上~~\n",
      "23 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "22 bottles 在啤酒墙上~~\n",
      "22 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "21 bottles 在啤酒墙上~~\n",
      "21 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "20 bottles 在啤酒墙上~~\n",
      "20 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "19 bottles 在啤酒墙上~~\n",
      "19 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "18 bottles 在啤酒墙上~~\n",
      "18 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "17 bottles 在啤酒墙上~~\n",
      "17 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "16 bottles 在啤酒墙上~~\n",
      "16 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "15 bottles 在啤酒墙上~~\n",
      "15 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "14 bottles 在啤酒墙上~~\n",
      "14 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "13 bottles 在啤酒墙上~~\n",
      "13 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "12 bottles 在啤酒墙上~~\n",
      "12 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "11 bottles 在啤酒墙上~~\n",
      "11 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "10 bottles 在啤酒墙上~~\n",
      "10 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "9 bottles 在啤酒墙上~~\n",
      "9 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "8 bottles 在啤酒墙上~~\n",
      "8 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "7 bottles 在啤酒墙上~~\n",
      "7 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "6 bottles 在啤酒墙上~~\n",
      "6 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "5 bottles 在啤酒墙上~~\n",
      "5 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "4 bottles 在啤酒墙上~~\n",
      "4 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "3 bottles 在啤酒墙上~~\n",
      "3 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "2 bottles 在啤酒墙上~~\n",
      "2 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "1 bottles 在啤酒墙上~~\n",
      "1 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "只剩1瓶了，不能给你了！\n"
     ]
    }
   ],
   "source": [
    "# 项目3 P44\n",
    "\n",
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上~~\")\n",
    "    print(beer_num,word,\"啤酒~~\")\n",
    "    print(\"拿一瓶走~~\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩1瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word, \"在啤酒墙上\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64997196",
   "metadata": {},
   "source": [
    "## 课后任务: 预习\n",
    "* 思考：什么是（seq type?）\n",
    "* 预习：数值，字符串\n",
    "> 1. \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
